<?php

/**
 * This is the model class for table "t_wechat_mchpay".
 *
 * The followings are the available columns in table 't_wechat_mchpay':
 * @property string $id
 * @property integer $com_id
 * @property string $mp_appid
 * @property string $mchid
 * @property string $nonce_str
 * @property string $partner_trade_no
 * @property string $openid
 * @property string $check_name
 * @property string $re_user_name
 * @property integer $amount
 * @property string $desc
 * @property string $spbill_create_ip
 * @property string $return_code
 * @property string $return_msg
 * @property string $create_time
 * @property string $update_time
 */
class WechatMchpayModel extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 't_wechat_mchpay';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('com_id, mp_appid, mchid, nonce_str, sign, partner_trade_no, openid, check_name, amount, spbill_create_ip, create_time', 'required'),
			array('com_id, amount', 'numerical', 'integerOnly'=>true),
			array('mp_appid, mchid, nonce_str, return_code, return_msg', 'length', 'max'=>50),
			array('partner_trade_no, desc', 'length', 'max'=>500),
			array('sign, openid, check_name', 'length', 'max'=>100),
			array('re_user_name', 'length', 'max'=>255),
			array('spbill_create_ip', 'length', 'max'=>20),
			array('update_time', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, com_id, mp_appid, mchid, nonce_str, partner_trade_no, openid, check_name, re_user_name, amount, desc, spbill_create_ip, return_code, return_msg, create_time, update_time', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'com_id' => 'Com',
			'mp_appid' => 'Mp Appid',
			'mchid' => 'Mchid',
			'nonce_str' => 'Nonce Str',
			'partner_trade_no' => 'Partner Trade No',
			'openid' => 'Openid',
			'check_name' => 'Check Name',
			're_user_name' => 'Re User Name',
			'amount' => 'Amount',
			'desc' => 'Desc',
			'spbill_create_ip' => 'Spbill Create Ip',
			'return_code' => 'Return Code',
			'return_msg' => 'Return Msg',
			'create_time' => 'Create Time',
			'update_time' => 'Update Time',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('com_id',$this->com_id);
		$criteria->compare('mp_appid',$this->mp_appid,true);
		$criteria->compare('mchid',$this->mchid,true);
		$criteria->compare('nonce_str',$this->nonce_str,true);
		$criteria->compare('partner_trade_no',$this->partner_trade_no,true);
		$criteria->compare('openid',$this->openid,true);
		$criteria->compare('check_name',$this->check_name,true);
		$criteria->compare('re_user_name',$this->re_user_name,true);
		$criteria->compare('amount',$this->amount);
		$criteria->compare('desc',$this->desc,true);
		$criteria->compare('spbill_create_ip',$this->spbill_create_ip,true);
		$criteria->compare('return_code',$this->return_code,true);
		$criteria->compare('return_msg',$this->return_msg,true);
		$criteria->compare('create_time',$this->create_time,true);
		$criteria->compare('update_time',$this->update_time,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return WechatMchpayModel the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
